<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$user_id = get_loggedin_userid();

$value = get_input('value');
$reference = get_input('reference');

$references = array (
    'com.greengar.drawtogether.colorpanel' => 370,
    'com.greengar.drawtogether.wordpack2' => 470,
    'com.greengar.drawtogether.wordpack3' => 570
);

$value = $references[$reference];

if(dt_use_coins($user_id, $value, $reference)) {
    echo json_encode(export_result(200, dt_export_coins($user_id)));
} else {
    $coins = dt_get_coins($user_id);
    echo json_encode(export_result(400, dt_export_coins($user_id)));
}

?>
